#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <iostream>
#include <vector>
#include <mpi.h>

#define TAG_JOB 1
#define TAG_TERMINATE 2

class Slave{
    
    public:
        Slave();	
        void SetParameters(int, int);
        void Start();
        
		virtual void Operation(char* inputBuffer, int size) { };
		
		void* WorkerThread(int receivedFrom);					
		
		static void* callWorkerThread(void *arg) 
		{ 
			int* argInt;
			argInt = (int*)arg;			
			return ((Slave*)arg)->WorkerThread(*argInt); 
		}
		
    private:        
        std::vector<pthread_t> threads;
        int slaveId;
        
        char *receiveBuffer; 
        int receiveBufferSize;
        
        void CreateThread(int receivedFrom);        

};
